<?php

if (function_exists('register_sidebar')) register_sidebar(array('before_widget' => '<li id="categories">','after_widget' => '</li>')); 

class Headerimg{
	var $style;
	var $version;

	function get_style(){
		$this->style = get_option('impact_style');
	}
}
	
$sevenimpact = new Headerimg();
$sevenimpact->get_style();
$sevenimpact->version = "0.13";

if (!get_option('impact_version') || get_option('impact_version') < $sevenimpact->version){
	if (!get_option('impact_version') )
		add_option('impact_version', $sevenimpact->version, 'Headerimg Version installed');
	else
		update_option('impact_version', $sevenimpact->version);
		
	if (!get_option('impact_style') )
		add_option('impact_style', '', 'Location of custom style sheet');
}

if ($_POST['custom_styles']){
	update_option('impact_style', $_POST['custom_styles']);
	wp_cache_flush();
	if ($_POST['custom_styles'] == 'none') $colored = "Blue"; 
	else
	$colored = substr($_POST['custom_styles'], 0, -4);
	$message  = "Color Styles change to <strong>". $colored."</strong>" ;
	$message  = strtoupper($message);
} else if( 'reset' == $_POST['action']) {
	delete_option( 'impact_style' );
	$message  = 'Styles changed to defaults!';
	}

add_action ('admin_menu', 'Headerimg_menu');

function Headerimg_menu() {
	add_submenu_page('themes.php', 'Color Options', 'Color Options', 5, 'functions.php', 'menu');
}

function menu() {
	global $sevenimpact, $message;
?>
<? if($message) : ?>
<div id="message" class="updated fade"><p><?=$message?></p></div>
<? endif; ?>

<div class="wrap" style="position:relative;">
<h2><?php _e('Color Options'); ?></h2>

<h3>Select Color Styles</h3>

<p><form name="dofollow" action="" method="post">
  <input type="hidden" name="page_options" value="'dofollow_timeout'" />
<input name="custom_styles" type="radio" id="impact_0" value="black.css" <?php if ($sevenimpact->style == "black.css") echo "checked='checked'"; ?> /> <label for="impact_0"><img src="/wp-content/themes/impact/img/black.gif" width="400px" height="40px"> Black</label><br />
<input name="custom_styles" type="radio" id="impact_1" value="style.css" <?php if ($sevenimpact->style == "style.css") echo "checked='checked'"; ?> /> <label for="impact_1"><img src="/wp-content/themes/impact/img/blue.gif" width="400px" height="40px"> Blue</label><br />
<input name="custom_styles" type="radio" id="impact_2" value="gold.css" <?php if ($sevenimpact->style == "gold.css") echo "checked='checked'"; ?> /> <label for="impact_2"><img src="/wp-content/themes/impact/img/gold.gif" width="400px" height="40px"> Gold</label><br />
<input name="custom_styles" type="radio" id="impact_3" value="green.css" <?php if ($sevenimpact->style == "green.css") echo "checked='checked'"; ?> /> <label for="impact_3"><img src="/wp-content/themes/impact/img/green.gif" width="400px" height="40px"> Green</label><br />
<input name="custom_styles" type="radio" id="impact_4" value="lilac.css" <?php if ($sevenimpact->style == "lilac.css") echo "checked='checked'"; ?> /> <label for="impact_4"><img src="/wp-content/themes/impact/img/lilac.gif" width="400px" height="40px"> Lilac</label><br />
<input name="custom_styles" type="radio" id="impact_5" value="red.css" <?php if ($sevenimpact->style == "red.css") echo "checked='checked'"; ?> /> <label for="impact_5"><img src="/wp-content/themes/impact/img/red.gif" width="400px" height="40px"> Red</label><br />
<input name="custom_styles" type="radio" id="impact_6" value="gray.css" <?php if ($sevenimpact->style == "gray.css") echo "checked='checked'"; ?> /> <label for="impact_6"><img src="/wp-content/themes/impact/img/gray.gif" width="400px" height="40px"> Gray</label><br />
</p>
<p class="submit left"><input type="submit" name="Submit" value="Apply Color Style &raquo;" /></p></form>
<form name="dofollow" method="post">
<p class="submit left"><input name="reset" type="submit" value="Default &raquo;" /><input type="hidden" name="action" value="reset" /></p></form>
<div class="clear"></div>
</div>

<?php
}
?>